package Rational;

import java.util.StringTokenizer;
public class Calculator{
         int numerator;
         int denominator;
         Calculator(){}
         Calculator(int a,int b){
                if(a==0){    
                      numerator = 0;
                      denominator = 1;}
                else{
                      setNumberatorAndDenominator(a,b);
                    }
                                }          
         void setNumeratorAndDenominator(int a,int b){
              int c = f(a,b);
              numerator = a/c;
              denominator = b/c;
         int getNumerator();{
                 return numerator;
                           }
         int getDenominator();{
                 return denominator;
                             }
         int f(int a,int b);{
             if(a<b){ int c = a;
                      a=b;
                      b=c;
                    }
             int r = a%b;
             while(r != 0){
                     a=b;
                     b=r;
                     r=a%b;
                          }
             return b;
                           } 
 
          Calculator add (Calculator r);{
             int a = r.getNumerator();
             int b = r.getDenominator();
             int newNumerator = numerator * b + denuoinator * a;
             int newDenominator = denominator * b;
             Calculator(newNumerator,newDenominator);
             return result;
                                      }
   
         





















